import React from 'react'
import './OrderDetails.less'
import Tit from '../../components/Tit'
import Address from '../../components/Address'
import OrderShop from '../../components/OrderShop'
import OrderBottom from '../../components/OrderBottom'
export default class OrderDetails extends React.Component {
    state = {
        OrderDetail: null
    }
    componentDidMount() {
        this.$postData('/api/order/getOrderMsg', { orderId: this.props.match.params.id }, params => {
            console.log(params)
            switch (params.code) {
                case 100:
                    this.setState({
                        OrderDetail: params.data
                    })
                    break;
                default:
                    this.Toast.info(params.msg);
                    break;
            }
        })
    }
    render() {
        console.log(this.props.match.params.id)
        return (
            <div>
                {this.state.OrderDetail ? <div className='OrderD FillO-page Address-white'>
                    <Tit zz={true} ID={1} tit={'订单详情'}></Tit>
                    <div className=''><Address ID={2}  index={0} address={this.state.OrderDetail}></Address></div>
                    {this.state.OrderDetail.voList.map((val, index) => (
                        <OrderShop key={index} data={val} ID={1} status={this.state.OrderDetail.status}></OrderShop>
                    ))}
                    <div className='OrderD-d1 xin-center'>
                        <p>订单编号:</p>
                        <p>{this.state.OrderDetail.orderNo}</p>
                    </div>
                    <div className='OrderD-d1 xin-center'>
                        <p>下单时间:</p>
                        <p>{this.state.OrderDetail.createTime }</p>
                    </div>
                    <div className='OrderD-d1 xin-center'>
                        <p>运费:</p>
                        <p>包邮</p>
                    </div>
                    <div className='OrderD-d1 xin-center'>
                        <p>优惠:</p>
                        <p>-¥{this.state.OrderDetail.orderDiscountPrice  }</p>
                    </div>
                    <div className='OrderD-d2'>
                        实付合计: ¥{this.state.OrderDetail.orderPayPrice }
                    </div>
                    <div className='OrderD-d3'>
                    {this.state.OrderDetail.status === 0 || this.state.OrderDetail.status === 2 || this.state.OrderDetail.status === 1 || this.state.OrderDetail.status === 3 ? <OrderBottom data={{ status: this.state.OrderDetail.status, orderPayPrice: this.state.OrderDetail.orderPayPrice, time: this.state.OrderDetail.time, id: this.state.OrderDetail.id }}></OrderBottom> : <div></div>}
                    </div>
                    <div className='diandi'></div>
                </div> : <div></div>}
            </div>
        )
    }
}